package com.coke.spring.sentinel.common;

import lombok.Data;

/**
 * @author cwm
 * @Description TODO
 * @date 2021/8/31 上午10:51
 * @Version 1.0
 */
@Data
public class Result {
    private static final Result INSTENCE= new Result();
    private Result(){
    }
    private Integer code;
    private String msg;
    private Object data;
    public static Result ok (Object data){
        INSTENCE.setMsg("操作成功");
        INSTENCE.setCode(200);
        INSTENCE.setData(data);
        return INSTENCE;
    }

    public static Result ok (String msg,Object data){
        INSTENCE.setMsg(msg);
        INSTENCE.setCode(200);
        INSTENCE.setData(data);
        return INSTENCE;
    }

    public static Result fail(Object data){
        INSTENCE.setMsg("操作失败");
        INSTENCE.setCode(500);
        INSTENCE.setData(data);
        return INSTENCE;
    }

    public static Result fail(String msg,Object data){
        INSTENCE.setMsg(msg);
        INSTENCE.setCode(500);
        INSTENCE.setData(data);
        return INSTENCE;
    }
}
